package com.tanhua.server.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.common.pojo.tanhua.Announcement;
import com.tanhua.server.mapper.AnnouncementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;

    public IPage<Announcement> queryAnnouncementList(Integer page, Integer pageSize){
        try {
            QueryWrapper<Announcement> queryWrapper = new QueryWrapper<>();
            queryWrapper.orderByDesc("created");
            return announcementMapper.selectPage(new Page<Announcement>(page, pageSize), queryWrapper);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
